package com.hmall.item.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hmall.item.mapper.ItemMapper;
import com.hmall.item.pojo.Item;
import com.hmall.item.service.IItemService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class ItemService extends ServiceImpl<ItemMapper, Item> implements IItemService {

    @Resource
    ItemMapper itemMapper;

    @Override
    public void putAndout(Long id, Integer status) {
        LambdaUpdateWrapper<Item> wrapper = new LambdaUpdateWrapper<Item>();
        wrapper.eq(Item::getId,id)
                .set(Item::getStatus,status);
        this.update(wrapper);
    }

    @Override
    public boolean downItemStockById(Long id, Integer num) {
        boolean flag = itemMapper.downStockById(id,num);
        return flag;
    }

}
